<%@ page import="weaver.general.Util" %>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    String json ="{\"flag\":\"0\"}";
    int requestid = Util.getIntValue(request.getParameter("requestid"));
    String rowindex = Util.null2String(request.getParameter("rowindex"));//主键
    int rownum = Util.getIntValue(rowindex) + 1;
    bb.writeLog("rownum=" + rownum);
    try {
        rs.executeQuery("select id from formtable_main_198 where requestid='" + requestid + "'");
        rs.next();
        String mainid = Util.null2String(rs.getString("id"));
        rs1.executeQuery("select f.id from formtable_main_198_dt1 f left join \n" +
                "(select ROW_NUMBER()over(order by id) as rownum ,* from formtable_main_198_dt1 where mainid='" + mainid + "' ) t on f.id = t.id \n" +
                "where f.mainid='" + mainid + "' and t.rownum='" + rownum + "'");
        rs1.next();
        String id = Util.null2String(rs1.getString("id"));
        rs1.executeUpdate("update formtable_main_198_dt1 set sfth='"+rowindex+"' where  mainid='" + mainid + "' and id ='" + id + "'");
        bb.writeLog("update formtable_main_198_dt1 set sfth='"+rowindex+"' where  mainid='" + mainid + "' and id ='" + id + "'");
        json = "{\"flag\":\"1\"}";
    } catch (Exception e) {
        e.printStackTrace();
    }
    out.print(json);
%>